// @ts-ignore
/* eslint-disable */
import { request } from 'umi';

/** 获取报警规则列表 GET /api/alarm/rules */
export async function queryAlarmRules(
  params: {
    // query
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
  },
  options?: { [key: string]: any },
) {
  return request<API.RequestData>('/api/alarm/rules', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

export async function getAlarmRulesByAttr(
  params?:any,
) {
 
  return request<API.DeviceItem>(`/api/alarm/rules/attr`, {
    method: 'GET',
    params: { ...params },

  });
}


export async function addAlarmRules(
  body: API.AlarmRulesItem,
  options?: { [key: string]: any },
) {
  return request<Record<string, any>>('/api/alarm/add', {
    method: 'POST',
    requestType:'form',
    data: body,
    ...(options || {}),
  });
}

/** 更新报警规则 PUT /api/alarm/rules */
export async function updateAlarmRules(body: API.AlarmRulesItem, options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/alarm/update', {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}
/** 更新报警规则 PUT /api/alarm/rules */
export async function updateOrsave(body: API.AlarmRulesItem, options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/alarm/updateOrsave', {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}


/** 删除报警规则 PUT /api/alarm/rules */
export async function removeAlarmRules(body: API.AlarmRulesItem, options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/alarm/del', {
    method: 'DELETE',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 报警规则详情 PUT /api/alarm/rules */
export async function alarmRulesDetail( params: { current?: number}) {
  return request<Map<string,object>>('/api/alarm/rules/detail', {
    method: 'GET',
    params: {
      ...params,
    },
  });
}

/** 批量更新设备UseState POST /api/device */
export async function batchUpdateState(body: object, options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/alarm/rules/batchUpdaten', {
    method: 'POST',
    requestType: 'form',
    data: body,
    ...(options || {}),
  });
}





export async function updateRulesDevice(
  body: Record<string, any>,
  options?: { [key: string]: any },
) {
  return request<Map<string,object>>('/api/alarm/rules/batchupdatedevice', {
    method: 'POST',
   
    requestType:'form',
    data: body,
    ...(options || {}),
  });
}


/** 删除规则DELETE  */
export async function batchRemoveRules(options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/alarm/rules/batchdel', {
    method: 'DELETE',
    params: {
      ...options,
    },
    ...(options || {}),
  });
}
